package pl.edu.uj.ii.battleships.activities;

import pl.edu.uj.ii.battleships.R;
import pl.edu.uj.ii.battleships.utils.GameDataManager;
import pl.edu.uj.ii.battleships.utils.Logger;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;

public class JoinActivity extends CustomActivity {
	
	private Button button_join;
	private TextView textview_nick;

	public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.join_layout);
        
        textview_nick = (TextView)findViewById(R.id.textview_nick);
        button_join = (Button)findViewById(R.id.button_join);
        button_join.setOnClickListener(new OnClickListener() {
			
			public void onClick(View v) {
				if(!textview_nick.getText().toString().equals("") || textview_nick.getText().toString() != null)
					GameDataManager.setMyNick(textview_nick.getText().toString());
				else {
					Toast t = Toast.makeText(getApplicationContext(), "Choose a nickname!", Toast.LENGTH_SHORT);
					t.show();
					return;
				}
				
				Intent intent = new Intent(v.getContext(), MyBoardActivity.class);
				startActivityForResult(intent, 0); 
			}
		});
        
        
	}
}
